package bean;

import lombok.*;

import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

/**
 * @classname:UserInfor
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/28 17:19
 * @version: 0.1
 * @since:1.8
 */

@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class UserInfo {
    private Integer id;
    private String name;
    private Integer age;
    private BigDecimal balance;
    private String image;
    @NonNull
    private Date birthday;
    private Date create_time;
    private Date update_time;
    private Integer roleid;
    private Integer status;

    public UserInfo(String name, Integer age, BigDecimal balance, String image, Date birthday, Integer roleid, Integer status) {
        this.name = name;
        this.age = age;
        this.balance = balance;
        this.image = image;
        this.birthday = birthday;
        this.roleid = roleid;
        this.status = status;
    }

    public UserInfo(ResultSet rs){
        try {
            this.id = rs.getInt("id");
            this.name= rs.getString("name");
            this.age = rs.getInt("age");
            this.balance = rs.getBigDecimal("balance");
            this.image = rs.getString("image");
            this.birthday = rs.getDate("birthday");
            this.create_time = (Date) rs.getObject("create_time");
            this.update_time = (Date) rs.getObject("update_time");
            this.roleid   =rs.getInt("roleid");
            this.status = rs.getInt("status");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

}
